<?php echo $this->callElement("default/tools/tool_bar",array("buttons"=>array( array("type"=>"back")) ,"title" => "MVC Manager")); ?>
<?php if( $action == 'create' ): ?>
    <form class="app_form">
        <?php
            App::Module('DataGrid')
                    ->addRow("Model Name",App::Load("Helper/Html")->inputTag("data[MVCManager][model]","",array("class"=>"app_input")))
                    ->addRow("Create Installer?",App::Load("Helper/Html")->checkboxTag("data[MVCManager][installer]",array("Yes"=>"Yes"),"Yes"))
                    ->addRow("Create Controller?",App::Load("Helper/Html")->checkboxTag("data[MVCManager][controller]",array("Yes"=>"Yes"),"Yes"))
                    ->addRow("Create View?",App::Load("Helper/Html")->checkboxTag("data[MVCManager][view]",array("Yes"=>"Yes"),"Yes"))
                    ->Render();
        ?>
    </form>
<?php  else: ?>
    <ul>
    <?php  
    foreach( $mvcdata as $mvckey => $mvcval ):  ?>
        <li>
        <div class="app_box">
            <h3 class="app_box_title toggler"><span class="box-button"> </span><?php echo $mvckey; ?> <?php echo $mvcval['model']['version']; ?></h3>
            <div class="box-body element">
                <div class="node">
                    <?php
                        $Grid = App::Module('DataGrid')->setDisplay('FormListing')->clear();
                        $Grid->addRow("Model Name",$mvcval['model']['name'] . " " . App::Load("Helper/Html")->linkTag( $this->baseurl("/developer/editor/" . base64_encode($mvcval['model']["path"]) . "/" . base64_encode(strtolower($mvcval['model']["name"]) . ".php")),"Edit"))
                             ->addRow("Model Version",$mvcval['model']['version'])
                             ->addRow("Model Table",($mvcval['model']['db_table']) ? $mvcval['model']['db_table'] : "<span style=\"color:#FF0000\">No Available</span>");

                        if( $mvcval['model']['insteller']['exists'] ):
                            $Grid->addRow("Installer",App::Load("Helper/Html")->linkTag( $this->baseurl("/developer/editor/" . base64_encode($mvcval['model']["path"] . "/installer/") . "/" . base64_encode(strtolower($mvcval['model']["name"]). ".php")),"Edit")); 
                        else:
                            $Grid->addRow("Installer","<span style=\"color:#FF0000\">No Available</span>");  
                        endif; 

                        if($mvcval['controller']['exists']) :
                            $Grid->addRow("Controller Name",$mvcval['controller']['name'] . " " . App::Load("Helper/Html")->linkTag( $this->baseurl("/developer/editor/" . base64_encode($mvcval['controller']["path"]) . "/" . base64_encode(strtolower($mvcval['controller']["name"]) . ".php")),"Edit"));
                        else:
                            $Grid->addRow("Controller Status","<span style=\"color:#FF0000\">No Available</span>");
                        endif;

                        if($mvcval['view']['exists']) :
                            $Grid->addRow("Total Views",count($mvcval['view']['files']));
                            $str = "";
                            foreach( $mvcval['view']['files'] as $val )
                            {
                                $str .= ($str!="" )  ? $this->get_tag("br","/") : $str;
                                $str .=  $val['file_name'] . " ".  App::Load("Helper/Html")->linkTag( $this->baseurl("/developer/editor/" . base64_encode($val["path"]) . "/" . base64_encode($val["file_name"])),"Edit") . " " . App::Load("Helper/Html")->linkTag($val['url'],"View");
                            }
                            $Grid->addRow("Manage Views","{$str} ");
                        else:
                            $Grid->addRow("View Status","<span style=\"color:#FF0000\">No Available</span>");
                        endif;
                        //$Grid->ondatabind->Subscribe("addButtons");
                        $Grid->Render();
                        ?>
                </div>
            </div>
        </div>
        </li>    
    <?php  endforeach; ?>
    </ul>
    <?php   if( $this->get_config('disable_accordion') != 'Yes') : ?>
    <script type="text/javascript">
       var myAccordion = new Accordion($('accordion'), 'h3.toggler', 'div.element', {
            opacity: false,
            onActive: function(toggler, element){
                toggler.setStyle('color', '#FFFFFF');
            },
            onBackground: function(toggler, element){
                toggler.setStyle('color', '#FFFFFF');
            }
        });
    </script>
    <?php endif; ?>
<?php endif; ?>

<?php echo $this->callElement("default/tools/tool_bar",array("buttons"=>array(array("type"=>"back")) ,"position" => 'bottom'));?>